﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BT_BieuThuc_Nhom13.Converter;

namespace BT_BieuThuc_Nhom13.Expressions
{
    public abstract class Expression
    {
        protected Expression cacheDerive;
        public virtual double Evaluate(double x)
        {
            return 0;
        }

        public virtual Expression Derive()
        {
            if (cacheDerive == null)
            {
                cacheDerive = this.CreateDerive();
            }

            return cacheDerive;
        }

        protected virtual Expression CreateDerive()
        {
            return null;
        }

        public override String ToString()
        {
            return String.Empty;
        }

        public virtual void SetConverter(MyConverter newConverter)
        {
        }
    }
}
